fludata <- read.table("~/Desktop/DingLu2015JRSSB_Code/fludata.txt", header=TRUE, quote="\"")
View(fludata)
##Preprocessing the data
fl = read.table("~/Desktop/DingLu2015JRSSB_Code/fludata.txt", header=TRUE, quote="\"")
Z = fl$assign
D = fl$receive
Y = fl$outcome
X = as.matrix(fl[, -c(1, 2, 3)])
N = length(Z)
require(nnet)
point = PSPS_M_weighting(Z, D, X, Y)
CACE.reg = point$CACE.reg
NACE.reg = point$NACE.reg
AACE.reg = point$AACE.reg
source('~/Desktop/DingLu2015JRSSB_Code/PS_M_weighting.R')
require(nnet)
point = PSPS_M_weighting(Z, D, X, Y)
CACE.reg = point$CACE.reg
NACE.reg = point$NACE.reg
AACE.reg = point$AACE.reg
head(X)
source('~/Desktop/DingLu2015JRSSB_Code/PS_M_weighting.R')
fl <- read.table("~/Desktop/DingLu2015JRSSB_Code/fludata.txt", header=TRUE, quote="\"")
View(fl)
Z = fl$assign
D = fl$receive
Y = fl$outcome
X = as.matrix(fl[, -c(1, 2, 3)])
N = length(Z)
require(nnet)
point = PSPS_M_weighting(Z, D, X, Y)
point
sg <- read.table("~/Desktop/DingLu2015JRSSB_Code/swogdata.txt", header=TRUE, quote="\"")
View(sg)
View(sg)
names(sg)
Z = sg$Z
N = length(Z)
D = ifelse(is.na(sg$score12), 0, 1)
Y = sg$score12 - sg$score0
Y[is.na(Y)] = 0
X = as.matrix(sg[, c(2, 8, 9, 10)]
)
names(X)
head(X)
colnames(X)
sg = sg[, -1]
view(sg)
View(sg)
sg = sg[, -c(2, 3, 4, 5)]
View(sg)
sg = sg[, -c(6, 7)]
View(sg)
getwd()
?save
save(sg, file = '/Users/jlu/Desktop/swogdata.txt')
sg = read.table("~/Desktop/DingLu2015JRSSB_Code/swogdata.txt", header=TRUE, quote="\"")
sg = read.table("~/Desktop/DingLu2015JRSSB_Code/swogdata.txt", header=TRUE, quote="\"")
head(swogdata)
head(sg)
Z = sg$Z
N = length(Z)
D = ifelse(is.na(sg$score12), 0, 1)
Y = sg$score12 - sg$score0
Y[is.na(Y)] = 0
X = as.matrix(cbind(sg$AGE, sg$RACEB, sg$RACEO, sg$score0))
head(X)
write.table(sg, "~/Desktop/DingLu2015JRSSB_Code/swogdata.txt", header=TRUE, quote="\"")
write.table(sg, "~/Desktop/DingLu2015JRSSB_Code/swogdata.txt")
head(sg)
sg = sg[, c(2, 7, 8, 9, 10, 13)]
head(sg)
write.table(sg, "~/Desktop/DingLu2015JRSSB_Code/swogdata.txt")
swogdata <- read.table("~/Desktop/DingLu2015JRSSB_Code/swogdata.txt", header=TRUE, quote="\"")
View(swogdata)
Z = sg$Z
N = length(Z)
D = ifelse(is.na(sg$score12), 0, 1)
Y = sg$score12 - sg$score0
Y[is.na(Y)] = 0
X = as.matrix(cbind(sg$AGE, sg$RACEB, sg$RACEO, sg$score0))
sg = read.table("~/Desktop/DingLu2015JRSSB_Code/swogdata.txt", header=TRUE, quote="\"")
Z = sg$Z
N = length(Z)
D = ifelse(is.na(sg$score12), 0, 1)
Y = sg$score12 - sg$score0
Y[is.na(Y)] = 0
X = as.matrix(cbind(sg$AGE, sg$RACEB, sg$RACEO, sg$score0))
source('~/Desktop/DingLu2015JRSSB_Code/PS_M_weighting_SA.R')
#decide the range of sensitivity parameter xi
p1 = sum(Z == 1 & D == 1)/sum(Z == 1)
p0 = sum(Z == 0 & D == 1)/sum(Z == 0)
xi.max = (p1 - p0)/min(p1, 1 - p0)
xi.max
require(nnet)
point = PSPS_M_weighting_SA(Z, D, X, Y)
#CACE, AACE and NACE
point$CACE.reg
point$AACE.reg
point$NACE.reg
point = PSPS_M_weighting_SA(Z, D, X, Y, eta = 0.1)
#SACE (i.e., AACE)
point$AACE.reg
